﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace FifaGamer
{
    /// <summary>
    /// Summary description for Register
    /// </summary>
    public static class Register
    {
        #region Public Static Methods
        public static bool Register_User(string firstname, string surname, string username, string email, DateTime? dateofbirth, string console, string console_id, string cellphone, bool? whatsapp, string skilllevel)
        {
            //setup account object
            var account = new Account(firstname, surname, username, email, dateofbirth, console, console_id, cellphone, whatsapp, skilllevel);

            //check if the account exists
            if (Register.Verify_User(account))
            {
                //create account
                int accountID = account.Create();

                //validate account creation
                if (Account.Verify_Exists(account.Email, account.Username))
                {
                    return true;
                }
            }           

            return false;
        }

        /// <summary>
        /// Validate a user
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static bool Verify_User(Account account) 
        {
            if (!Account.Verify_Exists(account.Email, account.Username))
            {
                if (string.IsNullOrWhiteSpace(account.Email)) { return false; }
                if (string.IsNullOrWhiteSpace(account.Username)) return false;

                return true;
            }           
            
            return false;   
        }

        /// <summary>
        /// Send the Register Notice
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static bool Send_RegisterNotice(Account account) { throw new NullReferenceException(); }

        /// <summary>
        /// Send the verify notice
        /// </summary>
        /// <param name="account"></param>
        /// <returns></returns>
        public static bool Send_WelcomeNotice(Account account) { throw new NullReferenceException(); }        
        #endregion
    }
}